package me.obstsalatt.guildera2.container;

import me.obstsalatt.guildera2.core.Guild;
import org.bukkit.entity.Player;

/**
 * Created with IntelliJ IDEA.
 * User: Robin
 * Date: 14.02.14, 17:23
 * Project: GuildEra2
 * Package: me.obstsalatt.guildera2.container
 * Descriprion:
 *      Ein Container für die Spieler
 */
public class GPlayer {
    private Player ply;
    private String rank;
    private String guildName;

    public GPlayer(Player ply) {
        this.ply = ply;
        this.guildName = "default";
        this.rank = "Stranger";
    }

    public GPlayer(Player ply, String rank, String guildName) {
        this(ply);
        this.rank = rank;
        this.guildName = guildName;
    }

    public Player getPlayer() {
        return ply;
    }

    public String getRank() {
        return rank;
    }

    public void setRank(String rankName) {
        rank = rankName;
    }

    public String getGuildName() {
        return guildName;
    }

    public void setGuild(Guild g) {
        this.guildName = g.getName();
        this.rank = g.getDefaultRank();
    }

    public void setGuild(Guild g, String rank) {
        this.guildName = g.getName();
        this.rank = rank;
    }

    public void removeGuild() {
        this.rank = "Stranger";
        this.guildName = "default";
    }

    public String toString() {
        return (ply.getName() + "#" + guildName + "#" + rank);
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GPlayer gPlayer = (GPlayer) o;

        if (!ply.equals(gPlayer.ply)) return false;

        return true;
    }

    public int hashCode() {
        return ply.hashCode();
    }
}
